import React from 'react';
import {Consumer} from "../context";

function One() {
    return (
        <div>
            <h3>One</h3>
            <Consumer>
                {
                    ({state,setState})=>{
                        return (
                            <div>
                                <p onClick={()=>setState({
                                    ...state,
                                    userName:state.userName+"!"
                                })}>userName:{state.userName}</p>
                                <p onClick={()=>setState({
                                    ...state,
                                    age:state.age+1
                                })}>age:{state.age}</p>
                            </div>
                        )
                    }
                }
            </Consumer>
        </div>
    );
}

export default One;